<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>ABRT Analytics - {% block title %}{% endblock title %}</title>
    <link rel="icon" type="image/png" href="{{ url_for('static', filename='icons/hicolor_apps_16x16_abrt.png')}}" sizes="16x16">
    <link rel="icon" type="image/png" href="{{ url_for('static', filename='icons/hicolor_apps_32x32_abrt.png')}}" sizes="32x32">
    <link rel="stylesheet" href="{{ url_for('system_static', component='patternfly', filename='css/patternfly.min.css')}}">
    <link rel="stylesheet" href="{{ url_for('system_static', component='patternfly', filename='css/patternfly-additions.min.css')}}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-multiselect.css')}}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/daterangepicker-bs3.css')}}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-tagsinput.css')}}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/typeaheadjs.css')}}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css')}}">

    <script type="text/javascript">
      ROOT_URL = "{{url_for('root')}}";
    </script>
    <script src="{{ url_for('system_static', component='jquery', filename='latest/jquery.min.js')}}"></script>
    <script src="{{ url_for('static', filename='js/bootstrap.js')}}"></script>
    <script src="{{ url_for('static', filename='js/bootstrap-multiselect.js')}}"></script>
    <script src="{{ url_for('system_static', component='patternfly', filename='js/patternfly.min.js')}}"></script>
    <script src="{{ url_for('static', filename='js/moment.js')}}"></script>
    <script src="{{ url_for('static', filename='js/daterangepicker.js')}}"></script>
    <script src="{{ url_for('static', filename='js/bootstrap-tagsinput.js')}}"></script>
    <script src="{{ url_for('static', filename='js/typeahead.bundle.min.js')}}"></script>
    <script src="{{ url_for('static', filename='js/custom.js')}}"></script>
    {% block js %}
    {% endblock js %}
  </head>
  <body>
      {% if config['BANNER'] %}
      <div class="alert alert-danger">
              <b>{{config.BANNER}}</b>
      </div>
      {% endif %}
      <div class="navbar navbar-default navbar-pf" role="navigation">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{{ url_for('root') }}"><strong class="brand-title">{{config.BRAND_TITLE}}</strong> {{config.BRAND_SUBTITLE}}</a>
          </div>
          <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-primary">
              <li {% if request.url_rule and request.url_rule.endpoint.startswith('summary.') %}class="active" {% endif %}><a href="{{ url_for('summary.index') }}">Summary</a></li>
              <li {% if request.url_rule and request.url_rule.endpoint.startswith('problems.') %}class="active" {% endif %}><a id="href_problems" href="{{ url_for('problems.dashboard') }}">Problems</a></li>
              <li {% if request.url_rule and request.url_rule.endpoint.startswith('reports.') %}class="active" {% endif %}><a href="{{ url_for('reports.dashboard') }}">Reports</a></li>
              <li class="dropdown" {% if request.url_rul and request.url_rule.endpoint.startswith('stats.') %}class="active" {% endif %} >
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Statistics <span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                  <li><a href="{{ url_for('stats.today') }}">Today</a></li>
                  <li><a href="{{ url_for('stats.yesterday') }}">Yesterday</a></li>
                  <li><a href="{{ url_for('stats.last_week') }}">Last week</a></li>
                  <li><a href="{{ url_for('stats.last_month') }}">Last month</a></li>
                  <li><a href="{{ url_for('stats.last_year') }}">Last year</a></li>
                </ul>
              </li>
              {% for menu_item in current_menu["public"] %}
                  <li {% if request.url_rule and request.url_rule.endpoint.startswith(menu_item['route']) %}class="active" {% endif %}><a href="{{ url_for(menu_item['route']) }}">{{menu_item["title"]}}</a></li>
                {% endfor %}
              {% if g.user.admin %}
                {% for menu_item in current_menu["admin"] %}
                  <li {% if request.url_rule and request.url_rule.endpoint.startswith(menu_item['route']) %}class="active" {% endif %}><a href="{{ url_for(menu_item['route']) }}"><i class="fa fa-gear"></i> {{menu_item["title"]}}</a></li>
                {% endfor %}
              {% endif %}
            </ul>
            {% if config['OPENID_ENABLED'] %}
              <ul class="nav navbar-nav navbar-utility">
                <li><a href="https://apps.fedoraproject.org/notifications" class="fa fa-bell notifications" title="Notifications preferences"></a></li>
                {% if g.user %}
                <li class="dropdown">
                  <a id="user-dropdown" role="button" data-toggle="dropdown">
                    <span class="fa fa-user fa-fw"></span>
                    <span class="dropdown-title">{{ g.user.username }}</span>
                    <span class="caret"></span>
                  </a>
                  <ul class="dropdown-menu" role="menu" aria-labeledby="user-dropdown">
                    <li role="option"><a role="button" href="{{ url_for('user.download') }}"><span class="fa fa-download fa-fw"></span>Download data</a></li>
                    <li role="option"><a role="button" data-toggle="modal" data-target="#userdata-delete"><span class="fa fa-trash-o fa-fw"></span>Delete data</a></li>
                    <li role="option"><a role="button" href="{{ url_for('login.do_logout') }}"><span class="fa fa-sign-out fa-fw"></span>Logout</a></li>
                  </ul>
                </li>
                {% else %}
                  <li><a href="{{ url_for('login.do_login') }}"><span class="fa fa-sign-in fa-fw"></span>Login</a></li>
                {% endif %}
              </ul>
              <div class="modal fade" id="userdata-delete" tabindex="-1" role="dialog" aria-labelledby="maildata-modal" aria-hidden="true">
                <div class="modal-dialog" role="document">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                      <h4 class="modal-title" id="maildata-modal">Delete data</h4>
                    </div>
                    <div class="modal-body">
                      <p>Do you really want to delete all the data associated with your account?</p>
                    </div>
                    <div class="modal-footer">
                      <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                      <a role="button" href="{{ url_for('user.delete') }}" class="btn btn-primary">Delete</a>
                    </div>
                  </div>
                </div>
              </div>
            {% endif %}
          </div>
      </div>
      {% with messages = get_flashed_messages(with_categories=true) %}
        {% if messages %}
          {% for category, message in messages %}
            <div class="alert alert-{{category}}" role="alert">{{ message }}</div>
          {% endfor %}
        {% endif %}
      {% endwith %}
      <div class="container-fluid">
        {% block body %}{% endblock %}
      </div>
      <div id="footer">
        <div class="container">
          {% block footer %}{% endblock %}
          ABRT Analytics v{{ config["FAF_VERSION"] }} |
          <a href="{{ url_for('about') }}">
            About
          </a>
          |
          <a href="https://github.com/abrt/faf/issues/new">
            Report a bug
          </a>
        </div>
      </div>
      {%- if config['FEDMENU_URL'] and config['FEDMENU_DATA_URL'] %}
      <script src="{{ config['FEDMENU_URL'] }}/js/fedmenu.js"></script>
      <script>
        fedmenu({
          'url': '{{ config["FEDMENU_DATA_URL"] }}',
          'mimeType': 'application/javascript',
          'position': 'bottom-right',
          {%- if component %}
          'package': '{{ component.name }}',
          {%- elif problem %}
            {%- if problem.unique_component_names | length == 1 %}
            {#- unique_component_names is a set, this gets the one item #}
            'package': '{{ problem.unique_component_names|first }}'
            {%- endif %}
          {%- endif %}
        });
     </script>
     {%- endif %}
  </body>
</html>
